package com.ffcs.cn.action.desktopcontrol.smpanelshrinkable;

import com.supermap.desktop.controls.ui.controls.SmDialog;
import com.supermap.desktop.controls.ui.controls.panels.SmPanelShrinkable;
import com.supermap.desktop.core.ui.controls.GridBagConstraintsHelper;

import javax.swing.*;
import java.awt.*;

/**
 * 可折叠的面板示例对话框
 *
  */
public class DialogSmPanelShrinkable extends SmDialog {
	private JButton jButton;
	private JCheckBox jCheckBox;
	private JPanel jPanel;
	private SmPanelShrinkable shrinkable;

	public DialogSmPanelShrinkable() {
		setTitle("可折叠的面板");
		setSize(new Dimension(200, 100));
		initComponents();
		initLayout();
	}

	private void initComponents() {
		jPanel = new JPanel();
		jButton = new JButton("按钮");
		jCheckBox = new JCheckBox("单选框");
		shrinkable = new SmPanelShrinkable("可折叠的面板", jPanel);
	}

	private void initLayout() {
		jPanel.setLayout(new GridBagLayout());
		jPanel.add(jButton, new GridBagConstraintsHelper(0, 0, 1, 1)
				.setInsets(GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.CONTROLS_GAP)
				.setWeight(1, 1)
				.setFill(GridBagConstraints.BOTH));
		jPanel.add(jCheckBox, new GridBagConstraintsHelper(1, 0, 1, 1)
				.setInsets(GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.CONTROLS_GAP)
				.setWeight(1, 1)
				.setFill(GridBagConstraints.BOTH));
		this.setLayout(new GridBagLayout());
		this.add(shrinkable, new GridBagConstraintsHelper(0, 0, 1, 1)
				.setInsets(GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.FRAME_CONTROL_GAP, GridBagConstraintsHelper.CONTROLS_GAP)
				.setWeight(1, 0)
				.setFill(GridBagConstraints.HORIZONTAL));
		this.add(new JPanel(), new GridBagConstraintsHelper(0, 2, 1, 1)
				.setWeight(1, 1)
				.setFill(GridBagConstraints.BOTH));
	}
}
